package models

import "gorm.io/gorm"

type House struct {
	gorm.Model
	Title  string
	Ads    string
	Price  float32
	Status int64 `gorm:"type:varchar(20);default:'正常';comment:'用户状态 1正常、2已正常发布房源、3冻结、4注销'"`
	UserId int64
}

func (h *House) GetHouseByUserId() error {
	return DB.Where("user_id=?", h.UserId).Limit(1).Find(&h).Error
}

func (h *House) CreateHouse() error {
	return DB.Create(&h).Error
}

func (h *House) UpdateHouse() error {
	return DB.Updates(&h).Error
}

func (h *House) GetHouseById() error {
	return DB.Where("d=?", h.ID).Limit(1).Find(&h).Error
}
